<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import lodash from "lodash"
export default {
  name: "app",
  created() {
    var _this = this
    window.H.hook.$on("vuex:init", function(state) {
      window.H.slideHistory.push(lodash.cloneDeep(state))
      window.H.slideIndex = 0
    })
    window.H.hook.$on("vuex:mutation", function(state) {
      if (window.H.slideHistory.length >= 10) {
        window.H.slideHistory.shift()
      }
      window.H.slideHistory = window.H.slideHistory.splice(
        0,
        window.H.slideIndex + 1
      )
      window.H.slideHistory.push(lodash.cloneDeep(state))
      window.H.slideIndex = window.H.slideHistory.length - 1
    })
    window.H.hook.$on("vuex:replace", function(index) {
      var state = lodash.cloneDeep(window.H.slideHistory[index])
      _this.$store.replaceState(state)
    })
    window.H.hook.$emit("vuex:init", _this.$store.state)
  },
}
</script>
